<template>
  <div class="edu-page-warp information-page">
    <!-- <el-card shadow="never"> -->
      <!-- <div slot="header">
        <span>信息公告</span>
      </div> -->
      <div class="information-view">
        <h1 class="info-title">{{information.title}}</h1>
        <div class="info-date">发布日期：{{information.createTime}}</div>
        <div class="info-content" v-html="information.content"></div>
        <div>
          <div v-for="attach in information.commonAttachmentList">
            <div @click="handleDownloadfile(attach.fileLacation, attach.fileName)">{{attach.fileName}}</div>
          </div>
        </div>
      </div>
    <!-- </el-card> -->
  </div>
</template>

<script>
  import { findCommonPublicMsgById } from 'common/src/api/public/information';
  import { downloadfile } from 'common/src/api/upload';
  import filters from "common/src/filters";

  export default {
    name: 'informationView',
    props: {
      id: [String, Number]
    },
    data: function() {
      return {
        information: {},
        informationId: ''
      }
    },
    created() {
      this.informationId = this.$props.id;
      console.log(this.informationId, '...........');
      this.handleFindCommonPublicMsgById(this.informationId);
    },
    mounted() {
      console.log(this.id, '...........');
    },
    methods: {
      setInformation(id) {
        this.informationId = id;
      },
      handleFindCommonPublicMsgById(id) {
        findCommonPublicMsgById(id).then(res => {
          this.information = res.data;
          this.information.createTime = filters.formatDate(this.information.createTime, "yyyy/MM/dd");
        });
      },
      handleDownloadfile(objectkey, filename) {
        if (!objectkey) return;
        downloadfile(filename ? objectkey + `&realName=${filename}` : objectkey);
      },
    }
    
  }
</script>

<style lang="scss" scoped>
  .information-view {
    .info-title, .info-date {
      text-align: center;
    }
    .info-content {
      margin-top: 15px;
      max-width: 100%;
    }
  }
  
</style>
